﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using ComModel;

namespace ComDAL
{
    public class Login_me
    {

        static string sert = ConfigurationManager.ConnectionStrings["myDB"].ConnectionString;
        private static SqlConnection conn = null;

        public static SqlConnection Conn
        {
            get
            {
                conn = new SqlConnection(sert);
                conn.Open();
                return Login_me.conn;
            }

        }

        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="name">姓名</param>
        /// <param name="pwd">密码</param>
        /// <returns> list集合查询</returns>
        public List<UserModel> Login_m(string name, string pwd, string email)
        {
            StringBuilder buder = new StringBuilder();
            List<UserModel> list = new List<UserModel>();
            try
            {


                buder.Append("  ");
                if (name != "" || name != null)
                {
                    buder.Append("");
                }
                if (pwd != null || pwd != "")
                {
                    buder.Append("");

                }
                if (email != "" || email != null)
                {
                    buder.Append("");
                }
                SqlCommand comm = new SqlCommand(buder.ToString(), Conn);
                SqlDataReader reder = comm.ExecuteReader();


                UserModel mo = null;
                while (reder.Read())
                {
                    mo = new UserModel();
                    mo.id = Convert.ToInt32(reder["id"]);
                    mo.user_email = reder["user_email"].ToString();
                    mo.user_face = reder["user_face"].ToString();
                    mo.user_loginTime = Convert.ToDateTime(reder["user_loginTime"]);
                    mo.user_name = reder["user_name"].ToString();
                    mo.user_password = reder["user_password"].ToString();
                    mo.user_phone = reder["user_phone"].ToString();
                    mo.user_regTime = Convert.ToDateTime(reder["user_regTime"]);
                    mo.user_sex = reder["user_sex"].ToString();
                    list.Add(mo);

                }

            }
            catch (Exception ee)
            {

                string mess = ee.Message;
            }

            finally
            {
                
            }
            return list;

        }

    }
}
